<?php
/**
 * Created by JetBrains PhpStorm.
 * User: h2a!
 * Date: 23/11/2012
 * Time: 10:54
 * To change this template use File | Settings | File Templates.
 */

Class Manage_Catalog_Model extends CI_Model{
    public function  get_all_catalogs() {
        $this->load->database();
        $query = $this->db->get('bh_category');
        return $query->result();
    }

    //get data of a catalog
    public function get_catalog($id = 0) {
        $this->load->database();
        $query = $this->db->get_where('bh_category',array('category_id' => $id));
        return $query->row_array();
    }

    //insert a catalog
    public function insert_category($data) {

        $this->db->insert('bh_category',$data);
    }

    public function edit_category($data, $id) {
        $this->load->database();
        $this->db->where('category_id',$id);
        $this->db->update('bh_category',$data);
    }

    //delete a product
    public  function delete_category($id) {
        $this->db->delete('bh_category', array('category_id' => $id));
    }
}
?>